﻿<div ng-controller="orderController">
    <div class="wrapper border-bottom white-bg page-heading">
        <div class="col-lg-pull-12">
            <ol class="breadcrumb">
                <li>订单</li>
            </ol>
        </div>
    </div>

    <form class="form-horizontal row">
        <div class="form-group">
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">客户手机号/姓名</label>
                <div class="col-sm-8">
                    <input name="merchant_id" type="text" class="form-control input-sm" ng-model="query.q">
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">订单号</label>
                <div class="col-sm-8">
                    <input name="order_no" type="text" class="form-control input-sm" ng-model="query.order_no">
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">来源</label>
                <div class="col-sm-8">
                    <select class="form-control input-sm" ng-model="query.order_type">
                        <option value="">全部</option>
                        <option value="0">爱地球</option>
                        <option value="1">海淘乐</option>
                        <option value="2">候鸟</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">订单时间</label>
                <div class="col-sm-8">
                    <div date class="input-group date">
                        <input class="form-control input-sm" ng-model="query.start_time">
                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="col-sm-8">
                    <div date class="input-group date">
                        <input class="form-control input-sm" ng-model="query.end_time">
                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">推单状态</label>
                <div class="col-sm-8">
                    <select class="form-control input-sm" ng-model="query.push_status">
                        <option value="">全部</option>
                        <option value="1">未推送</option>
                        <option value="2">已推送</option>
                        <option value="3">推送失败</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-4">
                <label class="col-sm-4 control-label">状态</label>
                <div class="col-sm-8">
                    <select class="form-control input-sm" ng-model="query.order_status">
                        <option value="">全部</option>
                        <option value="1">待付款</option>
                        <option value="2">已支付</option>
                        <option value="3">待确认</option>
                        <option value="4">已完成</option>
                        <option value="5">已关闭</option>
                    </select>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="col-sm-offset-4 col-sm-8">
                    <button class="btn btn-primary btn-sm" ui-sref="app.order.token_list(query)"><i class="fa fa-search"></i> 查询</button>
                    <a class="btn btn-primary btn-sm" id="export" ng-click="export()"><i class="fa fa-download"></i>导出</a>
                    <a class="btn btn-primary btn-sm" id="importDelivery" ng-click="openImportDelivery()"><i class="fa"></i>导入发货信息</a>
                </div>
            </div>
        </div>
    </form>
    <table class="table table-hover m-t-md">
        <thead>
            <tr style="background-color: #f7f7f9;">
                <th>订单号</th>
                <th>买家</th>
                <th>状态</th>
                <th>订单金额</th>
                <th>卖家货款</th>
                <th>运费</th>
                <th>补贴</th>
                <th>应付金额</th>
                <th>手续费</th>
                <th>实收金额</th>
                <th>订单时间</th>
                <th>推单状态</th>
                <th width="65">操作</th>
            </tr>
        </thead>
        <tbody ng-repeat="item in model.rows">
            <tr>
                <td colspan="10">
                    <p>支付方式：{{item.pay_info.pay_name}} 交易号：{{item.pay_info.pay_no}} 支付流水号：{{item.pay_info.transaction_no}} <br />商品名称：{{item.order_items[0].product_name}}</p>
                    <p ng-if="item.push_status==3">推送失败信息：<span style="color:red;">{{item.push_fail_msg}}</span></p>
                </td>
            </tr>
            <tr>
                <td>{{item.order_no}}</td>
                <td>{{item.shipping.ship_to}}<br />{{item.buyer.mobile}}</td>
                <td>{{get_order_status(item.status)}}</td>
                <td>{{item.order_amount > 0 || item.red_drill == 0 ? item.order_amount :""}}{{item.order_amount > 0 && item.red_drill > 0 ? " + " :""}}{{item.red_drill > 0 ? item.red_drill +"红钻" : ""}}</td>
                <td>{{item.amount > 0 || item.red_drill == 0 ? item.amount :""}}{{item.amount > 0 && item.red_drill > 0 ? " + " :""}}{{item.red_drill > 0 ? item.red_drill +"红钻" : ""}}</td>
                <td>{{item.freight}}</td>
                <td>{{item.subsidy_amount}}</td>
                <td>{{item.pay_amount > 0 || item.red_drill == 0 ? item.pay_amount :""}}{{item.pay_amount > 0 && item.red_drill > 0 ? " + " :""}}{{item.red_drill > 0 ? item.red_drill +"红钻" : ""}}</td>
                <td>{{item.fee_amount}}</td>
                <td>{{item.amount > 0 || item.red_drill == 0 ? item.amount :""}}{{item.amount > 0 && item.red_drill > 0 ? " + " :""}}{{item.red_drill > 0 ? item.red_drill +"红钻" : ""}}</td>
                <td>{{item.order_time}}</td>
                <td>{{get_push_status(item.push_status)}}</td>
                <td>
                    <a class="btn btn-primary btn-xs" ui-sref="app.order.detail({id:{{item.id}}})"><i class="fa fa-cog"></i> 详情</a>
                    <a class="btn btn-primary btn-xs" ng-if="(item.push_status==1 || item.push_status==3) && item.status==2" ng-click="stop(item.id)"><i class="fa fa-cog">停止推单</i></a>
                    <a class="btn btn-primary btn-xs" ng-if="item.status==3" ng-click="recipient(item.id)"><i class="fa fa-cog">确认收货</i></a>
                    <!--<a class="btn btn-primary btn-xs" ng-if="item.push_status==3" ng-click="push(item.order_no)"><i class="fa fa-cog">推单</i></a>-->
                </td>
            </tr>
        </tbody>
    </table>
    <div class="row">
        <div class="col-md-12">
            <uib-pagination total-items="model.total_result" items-per-page="model.size" ng-model="model.page" num-pages="model.total_pages"
                            ng-change="page(model.page)" class="pagination-sm" boundary-links="true" boundary-link-numbers="true" max-size="20"
                            previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></uib-pagination>
            <span class="pull-right" style="margin: 30px 0px 20px 0px">共{{model.total_result}} 当前：{{model.page}}/{{model.total_pages}}</span>
        </div>
    </div>
</div>

<script type="text/ng-template" id="import_delivery.html">
    <div class="modal-header">
        <h3 class="modal-title">导入发货信息</h3>
    </div>
    <form name="_form" class="form-horizontal w5c-form" w5c-form-validate="model.validateOptions" role="form" novalidate>
        <div class="modal-body">
            <div class="form-group">
                <label class="col-sm-3 control-label">发货信息文件</label>
                <div class="col-sm-6">
                    <input name="file" type="file" ngf-select ng-model="model.file" accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
                           class="form-control input-sm">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"></label>
                <div class="col-sm-6" style="color:#ff0000">
                    注：读取名为：Sheet1 的工作簿中的数据，第一行为列名
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button class="btn btn-primary" type="submit" w5c-form-submit="importDelivery()" btn-loading="psdisabled.save" loading-text="保存中..." ng-disabled="psdisabled.save">
                确定
            </button>
            <button class="btn btn-primary" type="button" ng-click="cancel()">取消</button>
        </div>
    </form>
</script>
